<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>[% block title %]Todo App[% endblock %]</title>
    <!-- 引入 Layui CSS -->
    <link href="[[ url_for('static', filename='css/layui.css') ]]" rel="stylesheet">
    <link rel="stylesheet" href="[[ url_for('static', filename='css/style.css') ]]">
    [% block extra_css %][% endblock %]
</head>
<body>
    <div class="layui-layout layui-layout-admin">
        <div class="layui-header">
            <div class="layui-logo">Todo App</div>
            <ul class="layui-nav layui-layout-right">
                [% if current_user.is_authenticated %]
                    <li class="layui-nav-item"><a href="/todos">我的待办</a></li>
                    <li class="layui-nav-item"><a href="/logout">退出</a></li>
                [% else %]
                    <li class="layui-nav-item"><a href="/login">登录</a></li>
                    <li class="layui-nav-item"><a href="/register">注册</a></li>
                [% endif %]
            </ul>
        </div>
        <div class="layui-body">
            <div class="layui-container" style="padding: 15px;">
                [% with messages = get_flashed_messages(with_categories=true) %]
                    [% if messages %]
                        [% for category, message in messages %]
                            <div class="layui-alert layui-alert-[[ category ]] layui-alert-dismissible">
                                [[ message ]]
                                <button type="button" class="layui-close" data-dismiss="alert"></button>
                            </div>
                        [% endfor %]
                    [% endif %]
                [% endwith %]
                [% block content %][% endblock %]
            </div>
        </div>
    </div>
    <!-- 引入 Axios -->
    <script src="[[ url_for('static', filename='js/axios.min.js') ]]"></script>
    <!-- 引入 Layui JS -->
    <script src="[[ url_for('static', filename='js/layui.js') ]]"></script>
    <!-- 配置 Layui -->
    <script>
    layui.config({
        base: '[[ url_for("static", filename="js/") ]]'
    });
    </script>
    <script src="[[ url_for('static', filename='js/main.js') ]]"></script>
    [% block extra_js %][% endblock %]
</body>
</html> 